@extends('shop::layouts.master')
@section('title')
    服务列表
@endsection
@section('tab')
    <div class="layui-fluid">
        <div class="layui-row layui-col-space15">
            <div class="layui-col-md12">
                <div class="layui-card">
                    <div class="layui-card-body ">
                        <form class="layui-form layui-col-space5">
                            <div class="layui-input-inline layui-show-xs-block">
                                <select name="pid">
                                    <option value="">服务类型</option>
                                    @foreach( $arr_search['type_list'] as $key => $vo )
                                         <option value="{{$key}}" @if($arr_search['pid'] == $key ) selected="selected" @endif> {{$vo}} </option>
                                    @endforeach
                                </select>
                            </div>

                            <div class="layui-input-inline layui-show-xs-block">
                                <button class="layui-btn" lay-submit="" lay-filter="sreach">
                                    <i class="layui-icon">&#xe615;</i>
                                </button>
                                <a class="layui-btn layui-btn-small" onclick="location.reload()" title="刷新">
                                    <i class="layui-icon layui-icon-refresh" style="line-height:30px"></i>
                                </a>
                            </div>
                        </form>
                    </div>
                    <div class="layui-card-body">
                        <button class="layui-btn" onclick="xadmin.open('添加配置','{{route("shop_road_rescue_create")}}')">
                            <i class="layui-icon"></i>添加</button>
                    </div>
                    <div class="layui-card-body layui_overflow_y ">
                        <table class="layui-table layui-form">
                            <thead>
                            <tr>
                                <th>编号</th>
                                <th>服务类型</th>
                                <th>收费类型</th>
                                <th>起始-结束公里数 -- 价格</th>
                                <th>操作</th></tr>
                            </thead>
                            <tbody>
                            @foreach($data as $key=>$value)
                                <tr class="phono_ine">
                                    <td>{{ $value['id'] }}</td>
                                    <td>{{ $arr_search['type_list'][$value['pid']]}}</td>
                                    <td>
                                        @if( $value['type'] == 1 )
                                                按次收费
                                            @else
                                                按公里数收费
                                        @endif
                                    </td>
                                    <td>
                                        @if( $value['type'] == 1 )
                                            ￥{{$value['price']}}
                                        @else
                                            @foreach( $value['extend'] as $k => $vo )
                                                {{$vo['startkm']}}KM 至 {{$vo['overkm']}}KM  收费 ￥{{$vo['price']}}  <br/>
                                            @endforeach
                                        @endif
                                    </td>
                                    <td>
                                        <a title="编辑" class="layui-btn" onclick="xadmin.open('编辑','{{route('shop_road_rescue_edit',['id'=>$value['id']])}}',$(window).width(),$(window).height())" href="javascript:;">
                                            编辑
                                        </a>
                                    </td>
                                </tr>
                            @endforeach
                            @if(empty($data))
                                <td colspan="66" align="center">暂无数据</td>
                            @endif
                            </tbody>
                        </table>
                    </div>
                    <div class="layui-card-body ">
                        <div class="page">
                            {{$page_link}}
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>

@endsection


@section('tab_js')
    <script>
        layui.use(['form', 'layer', 'jquery'], function () {
            $ = layui.jquery;
            var form = layui.form,
                layer = layui.layer;

            form.on('switch(switchTest)', function(data){
                var id = $(this).attr('data-id');
                var status = 1;
                if( $(this).attr('data-status') == 1 ){
                    status = 2;
                }
                $.ajax({
                    url: js_url('shop-coupon-update'),
                    type: 'post',
                    data: {id:id,status:status,'_token': '{{csrf_token()}}','act':'status'},
                    dataType: "json",
                    success: function (result) {
                        if (result.state === 0) {
                            layer.msg(result.msg, {time: 500, icon: 6}, function () {
                                //关闭当前frame
                                xadmin.close();
                                // 可以对父窗口进行刷新
                                xadmin.father_reload();
                            });
                        }else if( result.state === 2 ){
                            layer.msg(result.msg, {time: 1000, icon: 5}, function () {
                                location.reload();
                            });
                        } else {
                            layer.msg(result.msg, {time: 2000, icon: 5});
                        }
                    }
                });
            });

        })
    </script>
@endsection




